using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;  
using System.Text;
using System.Text.RegularExpressions;

namespace Coriander.Text.RegularExpressions
{
    public class PatternTokenList : List<PatternToken> 
    {
        /// <summary>
        /// Adds new token and returns it. Creates regular expression from
        /// <paramref name="pattern">pattern</paramref>.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pattern"></param>
        /// <returns></returns>
        public PatternToken Add(String name, String pattern)
        {
            Regex regex = new Regex(pattern, RegexOptions.Compiled);

            return Add(name, regex);
        }

        /// <summary>
        /// Adds new token and returns it
        /// </summary>
        /// <param name="name"></param>
        /// <param name="regex"></param>
        /// <returns></returns>
        public PatternToken Add(String name, Regex regularExpression)
        {
            PatternToken token = null;

            Add(token = new PatternToken(name, regularExpression));

            return token;
        }
    }
}
